package com.svms.service.bo;

import java.util.ArrayList;
import java.util.List;

import com.svms.model.SvmsTransport;
import com.svms.service.dml.impl.TransportDML;
import com.svms.service.iface.TransportIF;
import com.svms.service.mapper.TransportMapper;
import com.svms.service.vo.ResultCodeVO;
import com.svms.service.vo.TransportVO;

/**
 * @author
 * 
 */
public class TransportBO implements TransportIF {

	ResultCodeVO dBHitResult = new ResultCodeVO();
	TransportDML transportDML;

	public TransportDML getTransportDML() {
		return transportDML;
	}

	public void setTransportDML(TransportDML transportDML) {
		this.transportDML = transportDML;
	}

	@Override
	public ResultCodeVO insertNewtransport(TransportVO transport) {
		if (transportDML.transportValidator.checkMandatory(transport)) {
			dBHitResult = transportDML.insertNewTransport(transport);
		} else {
			
		}
		return dBHitResult;
	}

	@Override
	public ResultCodeVO deletetransport(TransportVO transport) {
		dBHitResult = transportDML.deleteTransport(transport);
		return dBHitResult;
	}

	@Override
	public TransportVO getTransport(TransportVO transport) {
		return TransportMapper.dmlToService(transportDML
				.getTransport(transport));
	}

	@Override
	public List<TransportVO> getTransportList() {
		List<SvmsTransport> svmsTransports = transportDML.getTransportList();
		List<TransportVO> transportsList = new ArrayList<TransportVO>();
		for (SvmsTransport svmsTransport : svmsTransports) {
			transportsList.add(TransportMapper.dmlToService(svmsTransport));
		}
		return transportsList;
	}
}
